<template>
      <div class="my-tag">
              <input
                class="input"
                type="text"
                placeholder="输入标签"
                v-if="isShow"
                @blur="isShow=false"  
                v-model="inputTag"
                @keydown.enter="changeTag"
                
              
              />
              <div v-else @dblclick="show" class="text">{{value}}</div>
            </div>
<!-- @blurj焦点事件   @dblclick双击事件-->
</template>

<script>
export default {
    name: 'MyRsy',

props:{
    value:{
        type:String,
        required:true
    }
},
    data() {
        return {
       isShow:false,
       inputTag:''
     
        }
    },

  
    methods: {
     show(){

    this.isShow=true
    //将父组件赋值给子组件
    this.inputTag=this.value

     },

changeTag(){
    //隐藏input框
    this.$emit('input',this.inputTag)
    this.isShow=false
}
    
    },
};
</script>

<style lang="less" scoped>
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}

</style>